﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MemoBoss
{
    public partial class GameOverDialog : UserControl
    {
        public GameOverDialog()
        {
            InitializeComponent();
        }
        Action<bool> Callback;
        //public PopupDialog(Action<bool> callback)
        //    : this()
        //{

        //    Callback = callback;
        //}
        bool DefaultResult = true;
        ScoreViewModel ScoreModel = new ScoreViewModel();
        public GameOverDialog(Action<bool> callback, Scoreloop.CoreSocial.API.Model.Score score, int highScore, int good, int bad, double performance, int performanceLevel, DifficultyLevel diff)
            : this()
        {
            GameScore.Text = string.Format("{0:#,##0}", score.Result);
            HighScore.Text = string.Format("{0:#,##0}", highScore);
            //MaxGoodBad.Text = string.Format("{0}/{1}", good, bad);
            //MovesToPairsRatio.Text = string.Format("{0:0%} (Level {1})", performance, performanceLevel);
            Callback = callback;
            ScoreBoard.DataContext = ScoreModel;
            ScoreModel.Items.Clear();
            ScoreModel.LoadGameScores(score, UpdateHighScore);
        }
        private void UpdateHighScore(int highScore)
        {
            HighScore.Text = string.Format("{0:#,##0}", highScore);
        }
        public bool ReturnDefault()
        {
            Callback(DefaultResult);
            return DefaultResult;
        }
        public void OnNavigatedTo() 
        {

            ScoreModel.EnsureProcessing();
           
        }
        private void btn2_Click(object sender, RoutedEventArgs e)
        {
            Callback(false);
        }

        private void btn1_Click(object sender, RoutedEventArgs e)
        {
            Callback(true);
        }


    }
}
